import { ajax } from '../http.js';
import { ajaxSync } from '../httpSync.js';

const AddressFindAllUrl = '/authc/address/find_all'; // 查询收货地址
const AddressFindUrl = '/authc/address/view'; // 查询单个收货地址
const AddressDeleteUrl = '/authc/address/delete'; // 删除收货地址
const AddressSaveUrl = '/authc/address/save'; // 新增收货地址
const AddressUpdateUrl = '/authc/address/update'; // 编辑收货地址
const AddressChioceUrl = '/district/find_list'; // 获取收货地址
const AddressSetDefaultUrl = '/authc/address/set_default'; // 设置默认收货地址
const PersonalCenterUrl = '/authc/user_rank/find_by_user_id'; // 查询用户个人资料、、个人中心
const UpdateMobileUrl = '/authc/user_rank/update_mobile'; // 修改手机号
const UpdateNickNameUrl = '/authc/user_rank/update_nick_name'; // 修改用户昵称
const UpdateUserFileUrl = '/authc/user_rank/update_user_file'; // 修改用户头像
const FindInviteInfoUrl = '/authc/user_rank/find_invite_info'; // 查询邀请人信息
const FindUserProtocolUrl = '/authc/user_rank/find_user_protocol_list'; // 查询用户协议列表
const ShortMessageSendCodeUrl = '/shortMessage/send_code'; // 发送验证码
const checkOldPhoneByCodeUrl = '/shortMessage/check_code'; // 校验旧手机短信验证码（用于修改手机号）
const AuthcUserSaveUrl = '/authc/user_identity/save'; // 保存实名认证信息
const FindByUserIdUrl = '/authc/user_identity/find_by_user_id'; // 通过userid查看实名认证信息
const UserUpdateAndResetUrl = '/authc/user_identity/update_and_reset'; // 编辑并重置实名认证信息
const BankCardFindBankListUrl = '/authc/bankcard/find_bankList'; // 银行卡列表
const BankCardFindBankPageUrl = '/authc/bankcard/find_bank_page'; // 查询银行
const BankCardDeleteByIdUrl = '/authc/bankcard/delete_byId'; // 删除用户绑定银行卡
const BankCardSaveBankCardUrl = '/authc/bankcard/save_bankCard'; // 用户绑定银行卡
const findBankUserProfileUrl = '/authc/bankcard/find_bank_user_profile'; // 判断用户是否可以填写银行卡
const UserRankCodeUrl = '/authc/user_rank/signin_qr_code'; // 调取用户二维码

const resetLoginPwUrl = '/authc/user_rank/set_pwd_by_code'; // 重置登录密码链接
const resetPayPwUrl = '/authc/user_rank/set_pay_password'; // 重置支付密码链接
const logoutUrl = '/authc/login_out'; // 登出
const getUserProtocolListUrl = '/authc/user_rank/find_user_protocol_list'; // 查看用户协议列表

const updatePersonalQualificationUrl = '/authc/user_qualification/v2/update_personal_qualification'; // 更新个人资质信息
const updateContractProxyUrl = '/authc/user_upgrade_apply/upload_contract_proxy'; // 上传委托个人签合同协议
const updateProxyUrl = '/authc/account_transfer/upload_proxy'; // 上传委托个人打款协议

const findBankUserProfileApi = (data, success, fail, opt) => { // 判断用户是否可以填写银行卡
  ajax({
    url: findBankUserProfileUrl,
    data: data,
    success: success,
    fail: fail,
    opt: opt
  });
};

const checkOldPhoneByCodeApi = (data, success, fail, opt) => { // 校验旧手机短信验证码（用于修改手机号）
  ajax({
    url: checkOldPhoneByCodeUrl,
    data: data,
    success: success,
    fail: fail,
    opt: opt
  });
};

const updatePersonalQualificationApi = (data, success, fail, opt) => { // 更新个人资质信息
  ajax({
    url: updatePersonalQualificationUrl,
    data: data,
    success: success,
    fail: fail,
    opt: opt
  });
};

const updateContractProxyApi = (data, success, fail, opt) => { // 上传委托个人签合同协议
  ajax({
    url: updateContractProxyUrl,
    data: data,
    success: success,
    fail: fail,
    opt: opt
  });
};

const updateProxyApi = (data, success, fail, opt) => { // 上传委托个人打款协议
  ajax({
    url: updateProxyUrl,
    data: data,
    success: success,
    fail: fail,
    opt: opt
  });
};

const getUserProtocolListApi = (data, success, fail, opt) => { // 查看用户协议列表
  ajax({
    url: getUserProtocolListUrl,
    data: data,
    success: success,
    fail: fail,
    opt: opt
  });
};

const logoutApi = (data, success, fail, opt) => {
  data = Object.assign(data, {
    token: uni.getStorageSync('user_token')
  });
  ajax({
    url: logoutUrl,
    data: data,
    success: success,
    fail: fail,
    opt: opt
  });
};

const resetPayPwApi = (data, success, fail) => { // 登录状态重置支付密码接口
  ajax({
    url: resetPayPwUrl,
    data: data,
    success: success,
    fail: fail
  });
};

const resetLoginPwApi = (data, success, fail) => { // 登录状态重置登录密码
  ajax({
    url: resetLoginPwUrl,
    data: data,
    success: success,
    fail: fail
  });
};

// 调取用户二维码
const UserRankCode = (data, success, fail) => {
  ajax({
    url: UserRankCodeUrl,
    data: data,
    success: success,
    fail: fail
  });
};
// 用户绑定银行卡
const BankCardSaveBankCard = (data, success, fail) => {
  ajax({
    url: BankCardSaveBankCardUrl,
    data: data,
    success: success,
    fail: fail
  });
};
// 删除用户绑定银行卡
const BankCardDeleteById = (data, success, fail) => {
  ajax({
    url: BankCardDeleteByIdUrl,
    data: data,
    success: success,
    fail: fail
  });
};
// 查询银行
const BankCardFindBankPage = (data, success, fail) => {
  ajax({
    url: BankCardFindBankPageUrl,
    data: data,
    success: success,
    fail: fail
  });
};

const BankCardFindBankPageSyncApi = (data, success, fail) => {
  return ajaxSync({
    url: BankCardFindBankPageUrl,
    data: data,
    success: success,
    fail: fail
  });
};
// 银行卡列表
const BankCardFindBankList = (data, success, fail) => {
  ajax({
    url: BankCardFindBankListUrl,
    data: data,
    success: success,
    fail: fail
  });
};

// 编辑并重置实名认证信息
const UserUpdateAndReset = (data, success, fail) => {
  ajax({
    url: UserUpdateAndResetUrl,
    data: data,
    success: success,
    fail: fail
  });
};
// 通过userid查看用户实名认证信息
const FindByUserId = (data, success, fail) => {
  ajax({
    url: FindByUserIdUrl,
    data: data,
    success: success,
    fail: fail
  });
};
// 保存实名认证信息
const AuthcUserSave = (data, success, fail) => {
  ajax({
    url: AuthcUserSaveUrl,
    data: data,
    success: success,
    fail: fail
  });
};
// 发送验证码
const ShortMessageSendCode = (data, success, fail) => {
  ajax({
    url: ShortMessageSendCodeUrl,
    data: data,
    success: success,
    fail: fail
  });
};
// 查询用户协议列表
const FindUserProtocol = (data, success, fail) => {
  ajax({
    url: FindUserProtocolUrl,
    data: data,
    success: success,
    fail: fail
  });
};
// 查询邀请人信息
const FindInviteInfo = (data, success, fail) => {
  ajax({
    url: FindInviteInfoUrl,
    data: data,
    success: success,
    fail: fail
  });
};
// 查询用户个人资料
const PersonalCenter = (data, success, fail) => {
  ajax({
    url: PersonalCenterUrl,
    data: data,
    success: success,
    fail: fail
  });
};

const personalCenterSync = (data, success, fail) => {
  return ajaxSync({
    url: PersonalCenterUrl,
    data: data,
    success: success,
    fail: fail
  });
};
// 修改手机号
const UpdateMobile = (data, success, fail) => {
  ajax({
    url: UpdateMobileUrl,
    data: data,
    success: success,
    fail: fail
  });
};
// 修改用户昵称
const UpdateNickName = (data, success, fail) => {
  ajax({
    url: UpdateNickNameUrl,
    data: data,
    success: success,
    fail: fail
  });
};
// 修改用户头像
const UpdateUserFile = (data, success, fail) => {
  ajax({
    url: UpdateUserFileUrl,
    data: data,
    success: success,
    fail: fail
  });
};
// 查询单个收货地址
const AddressFind = (data, success, fail) => {
  ajax({
    url: AddressFindUrl,
    data: data,
    success: success,
    fail: fail
  });
};
// 查询收货地址
const AddressFindAll = (data, success, fail) => {
  ajax({
    url: AddressFindAllUrl,
    data: data,
    success: success,
    fail: fail
  });
};
// 设置默认收货地址
const AddressSetDefault = (data, success, fail) => {
  ajax({
    url: AddressSetDefaultUrl,
    data: data,
    success: success,
    fail: fail
  });
};
// 删除收货地址
const AddressDelete = (data, success, fail) => {
  ajax({
    url: AddressDeleteUrl,
    data: data,
    success: success,
    fail: fail
  });
};
// 新增收货地址
const AddressSave = (data, success, fail) => {
  ajax({
    url: AddressSaveUrl,
    data: data,
    success: success,
    fail: fail
  });
};
// 编辑收货地址
const AddressUpdate = (data, success, fail) => {
  ajax({
    url: AddressUpdateUrl,
    data: data,
    success: success,
    fail: fail
  });
};
// 选择收货地址
const AddressChioce = (data, success, fail) => {
  ajax({
    url: AddressChioceUrl,
    data: data,
    success: success,
    fail: fail
  });
};

export {
  AddressDelete,
  AddressFindAll,
  AddressFind,
  AddressSave,
  AddressChioce,
  PersonalCenter,
  AddressUpdate,
  UpdateMobile,
  UpdateNickName,
  UpdateUserFile,
  FindInviteInfo,
  FindUserProtocol,
  ShortMessageSendCode,
  AuthcUserSave,
  BankCardFindBankList,
  BankCardFindBankPage,
  BankCardDeleteById,
  BankCardSaveBankCard,
  AddressSetDefault,
  FindByUserId,
  UserRankCode,
  UserUpdateAndReset,
  BankCardFindBankPageSyncApi,
  resetLoginPwApi,
  resetPayPwApi,
  logoutApi,
  getUserProtocolListApi,
  updatePersonalQualificationApi,
  updateContractProxyApi,
  updateProxyApi,
  personalCenterSync,
  checkOldPhoneByCodeApi,
  findBankUserProfileApi
};

